#!/bin/sh

# must not fail
set -e 

# debug
set -x 

echo "Starting $0"


SIGNCUSTOM_DISTNAME=signcustom_1_0_5.zip
SIGNCUSTOM_DIRNAME=signcustom_1_0_5
SIGNCUSTOM_SOFTLINK=signcustom
SIGNCUSTOM_UNPACKCMD=unzip


### copy to "install"

if [ ! -f ${DISTFILES_INSTALL}/${SIGNCUSTOM_DISTNAME} ] ; then 	
    echo "copying ${SIGNCUSTOM_DISTNAME} to ${DISTFILES_INSTALL}"
    cp ${SIGNCUSTOM_DISTNAME}     ${DISTFILES_INSTALL}
fi

### unpack if this version dont exist already
if [ -x ${SIGNCUSTOM_DIRNAME} ] ;then
    echo "${SIGNCUSTOM_DIRNAME} exists, skipping"
else

    cd ${INSTALL_INTO}
    ${SIGNCUSTOM_UNPACKCMD} ${DISTFILES_INSTALL}/${SIGNCUSTOM_DISTNAME} 
    cd -
fi


### soft links
rm -f ${SIGNCUSTOM_SOFTLINK}
ln -s ${SIGNCUSTOM_DIRNAME} ${INSTALL_INTO}/${SIGNCUSTOM_SOFTLINK}

### add to environment
echo "export SIGNCUSTOM_HOME=${INSTALL_INTO}/${SIGNCUSTOM_SOFTLINK}" >> ${INSTALL_INTO}/environment


### chmod
chown -R  ${appsrvuser}.${appsrvgrp} ${INSTALL_INTO}/${SIGNCUSTOM_DIRNAME}


echo "End of $0"


